Ext JS Essentials by Stuart Ashworth & Andrew Duncan

Ext JS Essentials by Stuart Ashworth & Andrew Duncan

Author:Stuart Ashworth & Andrew Duncan [Ashworth, Stuart]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2015-04-27T04:00:00+00:00


Configuring a proxy and data source

We will start by defining a proxy and simple static data source to connect our models to so that they can be populated. We do this with the following code pointing to two simple JSON files:

Ext.define('BizDash.model.Sale', { extend: 'Ext.data.Model', ... proxy: { type : 'ajax', url : 'sale.json', reader: { type: 'json' } } ... }); // sale.json [ { "id": 1, "userId": 1, "productId": 1, "Date" : "2014-08-04T14:41:17.220Z", "Quantity" : 1, "TotalCost": 9.99 }, { "id": 2, "userId": 1, "productId": 1, "Date" : "2014-08-03T14:41:17.220Z", "Quantity" : 2, "TotalCost": 19.98 } ] Ext.define('BizDash.model.User', { extend: 'Ext.data.Model', ... proxy: { type : 'ajax', url : 'user.json', reader: { type: 'json' } } ... }); // user.json { "id" : 99, "Name" : "Joe Bloggs", "Email" : "[email protected]", "TelNumber": " 07777777777", "Role" : "Salesman" }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.